# #!/usr/bin/python3
# # coding=utf-8
# #
# # Copyright (C) 2023-2024. Huawei Technologies Co., Ltd. All rights reserved.
# #
# # This program is distributed in the hope that it will be useful,
# # but WITHOUT ANY WARRANTY; without even the implied warranty of
# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# # ===============================================================================
#
# import numpy as np
# import torch
# from torch.nn import functional as F
#
# def gen_golden_data_simple():
#     input_src = (torch.rand(17, 1023) * (10 - (-10)) + (-10)).to(dtype=torch.float32)
#     golden = F.leaky_relu(input_src, 0.1).to(dtype=torch.float32)
#
#     input_src.numpy().tofile("./input/input_src.bin")
#     golden.numpy().tofile("./output/golden.bin")
#
#
# if __name__ == "__main__":
#     gen_golden_data_simple()

#!/usr/bin/python3
# coding=utf-8
#
# Copyright (C) 2023-2025. Huawei Technologies Co., Ltd. All rights reserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ===============================================================================

import numpy as np
import torch
from torch.nn import functional as F

dtype_emu = {torch.bfloat16: 0, torch.float16: 1, torch.float32: 2, torch.int8: 3, torch.int16: 4, torch.int32: 5}

def gen_golden_data_simple():
    dtype = torch.float32
    # dtype = bfloat16

    ## 核间均分，单核计算量对齐:
    # input_shape = [32, 1024]

    ## 核间均分，单核计算量非对齐:
    # input_shape = [8, 1023]

    ## 核间不均分，单核计算量对齐:
    # input_shape = [32, 1023]

    ## 核间不均分，单核计算量非对齐:
    input_shape = [17, 1023]
    input_src = (torch.rand(17, 1023) * (10 - (-10)) + (-10)).to(dtype=dtype)
    golden = F.leaky_relu(input_src, 0.1).to(dtype=dtype)

    tiling = np.array([input_shape[0] * input_shape[1], dtype_emu[dtype]], dtype=np.uint32)

    tiling.tofile("./input/input_tiling.bin")
    input_src.numpy().tofile("./input/input_x.bin")
    golden.numpy().tofile("./output/golden.bin")

if __name__ == "__main__":
    gen_golden_data_simple()
